<?php
/**
 * IG_Data
 *
 * @author mmxie
 * @copyright Copyright (c) 2009 Green Shore (http://www.iwgame.com)
 * @version $Id: Data.php 933 2011-10-27 09:00:03Z mmxie $
 */
class IG_Data
{
    /**
     * @var IG_Data_Adapter_Abstract
     */
    static public $adapter;

    /**
     * IG_Data
     * @param string $adapter
     * @param array $config
     * @return IG_Data_Adapter_Abstract
     */
    static public function factory($adapter, $config = array())
    {
        $className = 'IG_Data_Adapter_' . ucfirst($adapter);
        if (class_exists($className) && ($class = new $className($config)) instanceof IG_Data_Adapter_Abstract) {
            self::$adapter = $class;
            return $class;
        } else {
            throw new IG_Exception("'$className'方法不存在或不继承'IG_Data_Abstract'");
        }
    }
}